package Servlet;

import Bean.Register;
import Service.RegisterService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 张
 * Date: 2025-03-09
 * Time: 20:17
 */
//用户注册审核通过
@WebServlet("/RegisterDetailServlet")
public class RegisterDetailServlet extends HttpServlet {
    private RegisterService registerService = new RegisterService();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("application/json;charset=utf8");
        String registerId = req.getParameter("id");
        boolean ok = registerService.registerPass(registerId);
        if(!ok) {
            req.setAttribute("status", "error");
            req.setAttribute("message", "用户数据可能存在冲突!!");
            req.setAttribute("redirectUrl", "RegisterListServlet?pageNo=1");
            req.setAttribute("waitSeconds", 2);

        } else {
            req.setAttribute("status", "success");
            req.setAttribute("message", "操作成功!!!");
            req.setAttribute("redirectUrl", "RegisterListServlet?pageNo=1");
            req.setAttribute("waitSeconds", 2);
        }
        req.getRequestDispatcher("skip.jsp").forward(req,resp);

    }
}
